package com.dfiov.cloud.msmtools.utils;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
public class DateUtils {
    public static String dateToString(Date date) {
        if(date == null) {
            return null;
        }
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(date);
            return dateString;
        } catch (Exception e) {
            log.error("日期转换字符串失败:{}", JSON.toJSONString(e));
            return null;
        }
    }
}
